package cn.dengta.webapp.trade.service;

import javax.annotation.Resource;

import cn.dengta.webapp.base.service.BaseServiceImpl;
import cn.dengta.webapp.trade.dao.MaleRecommendStatisticsDao;
import cn.dengta.webapp.trade.entity.MaleRecommendStatistics;
import cn.dengta.webapp.user.entity.User;
import org.springframework.stereotype.Service;

/**
 * 男用户推荐分值统计 服务实现类
 *
 * @author zw
 * @since 2022-10-09
 */
@Service
public class MaleRecommendStatisticsService extends BaseServiceImpl<MaleRecommendStatistics, MaleRecommendStatisticsDao, Long> {


	@Resource
	FemaleRecommendStatisticsService femaleRecommendStatisticsService;


	public void add(Long userId) {
		MaleRecommendStatistics maleRecommendStatistics = MaleRecommendStatistics.of(userId);
		baseDao.insert(maleRecommendStatistics);
	}

	public void addMaleRecommend(Long userId) {
		MaleRecommendStatistics log = new MaleRecommendStatistics();
		log.setId(userId);
		baseDao.insert(log);
	}

	public void addFieldValue(Long userId, String field, Integer score) {
		baseDao.addFieldValue(field, score, userId);
	}

	public void coverFieldValue(Long userId, String field, Integer score) {

		baseDao.coverFieldValue(field, score, userId);
	}

	public void resetFieldScore(String field) {
		baseDao.resetFieldScore(field);
	}

	public void updateTotalSort() {
		baseDao.updateTotalSort();
	}

	/**
	 * 修改性别，重置推荐分值
	 */
	public void changeGender(User user) {
		femaleRecommendStatisticsService.deleteById(user.getId());
		add(user.getId());
	}
}
